<?php
error_reporting ( 0 );
session_start ();
header ( 'Content-Type: text/html; charset=UTF-8' );
require_once ("../in/tren.php");
echo '<div class="navigation"><b>Quản Lý Game</b></div><div align="right"><div style="border-top: 3px solid #13cfeb;"></div></div></div><div class="main_menu">';
if ($taikhoan ['quyen'] != 2) {
	header ( 'location:index.php' );
} else {
	switch ($_GET ['g']) {
		default :
			$tit = 'Thêm Thể Loại Game';
			echo 'Tên Thể Loại:<br><form action="ql.php?g=luutheloai" method="post"><input type="text" name="ten"><input type="submit" value="Thêm"></form></div>';
			break;
		case 'xoa' :
			$tit = 'Xóa Game';
			echo '&bull; Bạn thật sự muốn xóa?<br>[<a href="index.php?id=' . $_GET ['id'] . '">Không</a> | <a href="ql.php?g=xoaok&id=' . $_GET ['id'] . '">Đồng Ý</a>]</div>';
			break;
		case 'chuyen' :
			$array = @mysql_fetch_array ( mysql_query ( "select * from blog where id='{$_GET['id']}'" ) );
			$tit = 'Di Chuyển ' . $array ['tieude'];
			echo 'ID:<b>' . $_GET ['id'] . '<form action ="ql.php?g=okc&id=' . $_GET ['id'] . '" method="post"><br>&bull;Chọn thể loại muốn đến:<br><select name="theloai">';
			$sql = mysql_query ( "select `id`,`theloai` from `tlgame` order by theloai" );
			while ( $res = mysql_fetch_array ( $sql ) ) {
				echo '<option value="' . $res ['id'] . '">' . $res ['theloai'] . '</option>';
			}
			echo '</select><br>
<input type="submit" value="OK"></form></div>';
			break;
		case 'okc' :
			mysql_query ( "UPDATE `game` SET theloai = '" . $_POST ['theloai'] . "' WHERE `id`='" . ( int ) $_GET ['id'] . "' LIMIT 1;" );
			header ( 'Location:index.php?id=' . $_GET ['id'] . '' );
			break;
		case 'sua' :
			$array = @mysql_fetch_array ( mysql_query ( "select * from game where id='{$_GET['id']}'" ) );
			$tit = 'Sửa Game ' . $array ['tieude'] . '';
			echo 'ID:<b>' . $array ['id'] . '</b><br/><form action="ql.php?g=luu&id=' . $_GET ['id'] . '" method="post">&bull;Tiêu Đề( Max 50):<br>
<input type="text" name="tieude" value="' . $array ['tieude'] . '" size="15"/><br>
&bull;Sản Xuất( Max 50):<br>
<input type="text" name="sanxuat" value="' . $array ['sanxuat'] . '" size="15"/><br>&bull;Màn Hình( số):<br>
<input type="text" name="manhinh" value="' . $array ['manhinh'] . '" size="15"/><br>&bull;Mô tả( Max 500):<br/><textarea cols="20" name="mota" rows="7"/>' . $array ['mota'] . '</textarea><br>
<input type="submit" value="Thay đổi"></form></div>';
			break;
		case 'luu' :
			$mota = htmlspecialchars ( $_POST ['mota'] );
			$tieude = htmlspecialchars ( $_POST ['tieude'] );
			$sanxuat = htmlspecialchars ( $_POST ['sanxuat'] );
			mysql_query ( "UPDATE `game` SET `mota`='" . $mota . "', `tieude`='" . $tieude . "', `sanxuat`='" . $sanxuat . "', `manhinh`='" . $_POST ['manhinh'] . "' WHERE `id`='" . $_GET ['id'] . "' LIMIT 1;" );
			header ( 'Location:index.php?id=' . $_GET ['id'] . '' );
			break;
		case 'xoaok' :
			$array = @mysql_fetch_array ( mysql_query ( "select * from game where id='{$_GET['id']}'" ) );
			$link = $array ['link'];
			@unlink ( '../fgame/' . $link . '' );
			mysql_query ( "DELETE FROM `game` WHERE `id`='" . $_GET ['id'] . "'" );
			mysql_query ( "DELETE FROM `giohang` WHERE `idgame`='" . $_GET ['id'] . "'" );
			header ( 'Location:index.php' );
			break;
		case 'doiten' :
			$array = @mysql_fetch_array ( mysql_query ( "select * from tlgame where id='{$_GET['id']}'" ) );
			$tit = 'Đổi Tên ' . $array ['theloai'] . '';
			echo 'ID:<b>' . $array ['id'] . '</b><br/><form action="ql.php?g=luudt&id=' . $_GET ['id'] . '" method="post">&bull;<input type="text" name="theloai" value="' . $array ['theloai'] . '" size="15"/><input type="submit" value="Thay đổi"></form></div>';
			break;
		case 'luudt' :
			$theloai = htmlspecialchars ( $_POST ['theloai'] );
			mysql_query ( "UPDATE `tlgame` SET `theloai`='" . $theloai . "' WHERE `id`='" . $_GET ['id'] . "' LIMIT 1;" );
			header ( 'Location:theloai.php?id=' . $_GET ['id'] . '' );
			break;
		case 'luutheloai' :
			$ten = htmlspecialchars ( $_POST ['ten'] );
			mysql_query ( "INSERT INTO `tlgame` SET `theloai` = '" . $ten . "' " );
			echo 'Lưu thành công!<br>
&raquo<a href="ql.php">Tạo tiếp thể loại</a><br>
&laquo<a href="index.php">Về Trang Chính</a></div>';
			break;
	}
}
require_once ("../in/duoi.php");
?>
